package com.lmxdawn.api.admin.dao.auth;

import com.lmxdawn.api.admin.entity.auth.AuthAdmin;
import com.lmxdawn.api.admin.req.auth.AuthAdminQueryRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Collection;
import java.util.List;

@Mapper
public interface AuthAdminDao {

    /**
     * 后台业务查询列表
     * @return 列表
     */
    List<AuthAdmin> listAdminPage(AuthAdminQueryRequest authAdminQueryRequest);

    /**
     * 根据id查询
     * @param id 传入的id
     * @return
     */
    AuthAdmin findById(String id);

    /**
     * 根据id查询 password
     * @param id 传入的id
     * @return
     */
    AuthAdmin findPwdById(String id);

    /**
     * 根据Name
     * @param userName 用户名
     * @return
     */
    AuthAdmin findByUserName(String userName);

    /**
     * 插入
     * @param authAdmin
     * @return
     */
    boolean insertAuthAdmin(AuthAdmin authAdmin);

    @Update("update auth_admin set online_status = #{status} where id = #{id}")
    boolean updateOnlineStatus(String status, String id);
    /**
     * 更新
     * @param authAdmin
     * @return
     */
    boolean updateAuthAdmin(AuthAdmin authAdmin);

    /**
     * 删除
     * @param id
     * @return
     */
    boolean deleteById(String id);

    List<AuthAdmin> listAll();

    void unbind(String id);

    List<AuthAdmin> listByIds(@Param("list") Collection<?> jimOnlineUser);

    @Select("select * from auth_admin where last_login_time < (now() - INTERVAL 30 MINUTE) and online_status= 1 ")
    List<AuthAdmin> listExpireUser();
}
